// pages/forth/forth.js
var app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isShow:false,
    isShow0:false,
    isShow1:false,
    isShow2:false,
    isShow3:false,
    isShow4:false
  },
  search:function(){
    console.log('search')
    var that=this
    wx.request({
      url: 'https://jubrigs.market.alicloudapi.com/car-evaluate/evaluate',
      method:'POST',
      header:{'Authorization':'APPCODE be94d6101e0c4a3789385026bd6642de','Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},
      data:{
        buyCarDate:app.globalData.buyCarDate,
        city:that.data.city,
        mileage:app.globalData.mileage,
        trimId:that.data.id
      },
      success(res){
          that.setData({
            ncmsrp:res.data.data.ncmsrp,
            b2CPrices:res.data.data.b2CPrices,
            c2BPrices:res.data.data.c2BPrices
          })
          console.log(that.data.ncmsrp)
          console.log(that.data.b2CPrices.a.low)
          console.log(that.data.c2BPrices)
      }
    })
  },
  city:function(){
    console.log('city')
    var that=this
    wx.request({
      url: app.globalData.url+'/city',
      data:{
        city:app.globalData.city
      },
      success(res){
        console.log(res)
        that.setData({
          city:res.data
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this
    that.city()
    wx.request({
      url: 'https://jubrigs.market.alicloudapi.com/vehicle/new-car-price',
      method:'POST',
      header:{'Authorization':'APPCODE be94d6101e0c4a3789385026bd6642de',
      'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},
      data:{vin:app.globalData.carNumber},
      success(res){
        console.log(res)
        if(res.data.code=='200'){
          that.setData({
            id:res.data.data.styles[0].id
          })
          that.search()
        }
        else{
          that.setData({
            err:'未查询到车辆信息'
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})